package com.woniuxy.dr_mall.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.woniuxy.dr_mall.entity.DrPicture;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 张哲轩
 * @since 2021-08-11
 */
public interface DrPictureMapper extends BaseMapper<DrPicture> {


    @Select("select * from dr_picture where productId=#{productId}")
    List<DrPicture> getPicturesByProductId(int productId);
    /**
    * @Description:根据商品id查询其默认图片
    * @Param: [productId]
    * @return: com.woniuxy.dr_mall.entity.DrPicture
    * @Author: 杨耀
    * @Date: 2021/8/19
    * @Time: 14:54
    */
    @Select("select * from dr_picture where isdefault='y' and productId=#{productId}")
    DrPicture getPictureByProductId(int productId);

    //通过商品id，isdefault=y商品的图片 叶官鑫 2021-8-18
    @Select("select * from dr_picture where isdefault='y' and  productId=#{productId}")
    DrPicture selectProductsPicture(int productId);

    @Select("select image from dr_picture where productId=#{productId}")
    List<String> getImageByProductId(int productId);


    @Insert("insert into dr_picture(productId,image,commentId,isdefault) values(#{productId},#{image},#{commentId},#{isDefault})")
    void CommentPictureAdd(DrPicture drPicture);

    @Select("select image from dr_picture where commentId = #{commentId}")
    //List<String> getCommentImageByCId(@Param("commentId")int commentId);
    String[] getCommentImageByCId(@Param("commentId")int commentId);

    @Select("select image from dr_picture where commentId = #{commentId}")
        //List<String> getCommentImageByCId(@Param("commentId")int commentId);
    List<String> getCommentImagesByCId(@Param("commentId")int commentId);
}
